package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FAudit;
import com.ruoyi.system.service.IFAuditService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审计和合规性Controller
 * 
 * @author qi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/audit")
public class FAuditController extends BaseController
{
    @Autowired
    private IFAuditService fAuditService;

    /**
     * 查询审计和合规性列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(FAudit fAudit)
    {
        startPage();
        List<FAudit> list = fAuditService.selectFAuditList(fAudit);
        return getDataTable(list);
    }

    /**
     * 导出审计和合规性列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:export')")
    @Log(title = "审计和合规性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FAudit fAudit)
    {
        List<FAudit> list = fAuditService.selectFAuditList(fAudit);
        ExcelUtil<FAudit> util = new ExcelUtil<FAudit>(FAudit.class);
        util.exportExcel(response, list, "审计和合规性数据");
    }

    /**
     * 获取审计和合规性详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:query')")
    @GetMapping(value = "/{fAuditid}")
    public AjaxResult getInfo(@PathVariable("fAuditid") Long fAuditid)
    {
        return success(fAuditService.selectFAuditByFAuditid(fAuditid));
    }

    /**
     * 新增审计和合规性
     */
    @PreAuthorize("@ss.hasPermi('system:audit:add')")
    @Log(title = "审计和合规性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FAudit fAudit)
    {
        return toAjax(fAuditService.insertFAudit(fAudit));
    }

    /**
     * 修改审计和合规性
     */
    @PreAuthorize("@ss.hasPermi('system:audit:edit')")
    @Log(title = "审计和合规性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FAudit fAudit)
    {
        return toAjax(fAuditService.updateFAudit(fAudit));
    }

    /**
     * 删除审计和合规性
     */
    @PreAuthorize("@ss.hasPermi('system:audit:remove')")
    @Log(title = "审计和合规性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fAuditids}")
    public AjaxResult remove(@PathVariable Long[] fAuditids)
    {
        return toAjax(fAuditService.deleteFAuditByFAuditids(fAuditids));
    }
}
